package org.jgs1904.tieba.config;

import org.jgs1904.tieba.interceptors.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author junki
 * @date 2020/5/14 16:54
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册登录拦截器
        InterceptorRegistration registration = registry.addInterceptor(new LoginInterceptor());
        // 配置登录拦截器
        registration.addPathPatterns("/**");
        registration.excludePathPatterns(
                "/user/login",
                "/user/regist",
                "/kaptcha",
                "/user/forget",
                "/post/page",
                "/post/detail",
                "/**/*.jpg",
                "/**/*.js",
                "/**/*.css",
                "/ckeditor/**"
        );
    }

}
